<%--
 *  File:    ConditionDetail.jsp
 *  @Author: Hilldao
 *  Date:    2002/1/8
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.ConditionDetail");
  String strTableName = "ovcondtiondetail";
  String strModuleName = "PCM";
  String privilegeCode = "Z0610,L205";
  %>



<%

  //get userinfo
  HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");

  String conditionid = request.getParameter("conditionid");
  if(conditionid==null)
    conditionid = "";
%>
<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title></title>
<PageFlow:CheckPageFlow pageName="conditiondetail"/>
<%@ include file="/inc/InitEdit.inc" %>
<%
  OvalCustomColumn column = new OvalCustomColumn(strLanguageCode);
  Vector CondtionDetail = (Vector)pageContext.getAttribute("conditiondetails");
  if(CondtionDetail == null)
    CondtionDetail = new Vector();

  HashMap conditioninfo = (HashMap)pageContext.getAttribute("conditioninfo");
  if(conditioninfo == null)
    conditioninfo = new HashMap();

  String VTable = "";
  if(conditioninfo.get("transtable")!=null)
    VTable = (String)conditioninfo.get("transtable");
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<script language="JavaScript">

parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
function page_delete()
{
    var isSelectItem = false;
	  var checkitem = document.all.item('detailids');
	  for(var i = 1; i<checkitem.length;i++)
	  {
	    <%--[SCRIPT]  alert("i->"+i+"--"+checkitem[i].value);  [SCRIPT]--%>
	    if(checkitem[i].value!=-1)
	    {
	      isSelectItem = true;
	      break;
	    }
	  }
	  if(isSelectItem)
	  {
		  var flag = confirm('<%=message.getMessageDesc("ARE_YOU_SURE_DEL")%>');
		  if(!flag)
		    return;
		  document.condetailform.actionname.value = "remove";
		  isRunning = true;
		  document.condetailform.submit();
		}
		else
		{
		    alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
		}
}
function item_onclick(i,clickid)
{
  var itemname = "detailids"+i;
  <%--[SCRIPT]  alert(document.condetailform.detailids[i].value);  [SCRIPT]--%>
  <%--[SCRIPT]  alert(document.condetailform.checkconditiondetail[i].value);  [SCRIPT]--%>
  if(document.all.item("conditiondetail"+i).checked == true)
  {
    document.condetailform.detailids[i].value = clickid;
  }
  else
  {
    document.condetailform.detailids[i].value = -1;
  }
}
function page_add()
{
  var type = document.all.item("conditiontype").value;
  parent.down.location.href = "ConditionDetailAdd.jsp?<%= OvalTools.randomURL() %>&conditionid=<%=JspHelper.filterNull(conditionid)%>&languagecode=<%= strLanguageCode %>&conditiontype="+type+"&transtable=<%=JspHelper.filterNull( conditioninfo.get("transtable") )%>";
}

function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(condetailform,actionvalue,orderbyname);
  editform.action = "ConditionDetail.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}
  function page_edit()
  {
         var id = condetailform.conditionid.value;
         var detailidArr= condetailform.detailids;
         var type = document.all.item("conditiontype").value;
<%--         alert(detailidArr);--%>
         var count=0;
         var detailid;
         for(var i=1;i<detailidArr.length;i++){
                    //alert(detailidArr[i].value);
                    if (detailidArr[i].value!=-1){
                        detailid=detailidArr[i].value;
                        count++;
                    }
         }
         //alert("count"+count);
         if(count==0)   {
		    alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
            return;
         }
         if(count>1) {
		    alert('<%=message.getMessageDesc("PLEASE_SELECT_ONLY_ONE")%>');
            return;
         }

         //alert("xxx");
	  if(id == null || id.length == 0 || id == "" || id == "-1")
	    return;
      if(count==1) {
	              // alert("detailid"+detailid);
	               parent.down.location.href = "ConditionDetailEdit.jsp?&conditionid=<%=JspHelper.filterNull(conditionid)%>&languagecode=<%= strLanguageCode %>&transtable=<%=JspHelper.filterNull( conditioninfo.get("transtable") )%>&conditiontype="+type+"&conditiondetailid="+detailid;
     }
}

</script>

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellspacing="0">
 <form name="condetailform" method="post" action="../../Dispatcher"  target="_parent">
   <input type="hidden" name="pagename" value="conditiondetail">
	 <input type="hidden" name="actionname">
	 <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">

	 <input type="hidden" name="conditionid" value="<%=JspHelper.filterNull( conditionid )%>">
	 <input type="hidden" name="conditiondetailid" >
	 <input type="hidden" name="conditiontype" value="<%=JspHelper.filterNull( conditioninfo.get("conditiontype"))%>">
	 <input type="hidden" name="conditionidsession" value="<%=JspHelper.filterNull( conditionid)%>">

<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td class="summary_top"></td>
  </tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top"><img src="../../images/<%= strLanguageCode %>/quote.gif"> <%=JspHelper.filterNull((String)conditioninfo.get("conditioncode")+ "   " + (String)conditioninfo.get("conditiondesc"))%><%= label.getLabelName("L_Colon") %></td>
  </tr>
    <tr>
      <td valign="top">
        <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="0">
          <tr class="deepblue-left">
            <td class="title_center" width="5%">&nbsp;</td>
            <td class="title_center" width="8%" ><a href="javascript:page_summary('orderby','sortno')"><%= label.getLabelName("L_Sequence") %></a></td>
            <td class="title_center" width="12%" ><a href="javascript:page_summary('orderby','fieldname')"><%= label.getLabelName("L_FieldName") %></a></td>
            <td class="title_center" width="8%" ><a href="javascript:page_summary('orderby','operator')"><%= label.getLabelName("L_Operator") %></a></td>
            <td class="title_center" width="15%" ><a href="javascript:page_summary('orderby','value')"><%= label.getLabelName("L_Value") %></a></td>
            <td class="title_center" ><a href="javascript:page_summary('orderby','memo')"><%= label.getLabelName("L_Comment") %></a></td>
          </tr>

          <%
             int j = 0;
             String strClassType = new String();
          %>
          <logic:iterate id="condetail" collection="<%= CondtionDetail %>">
         <%
            HashMap ConditionDetailMap = (HashMap)pageContext.getAttribute("condetail");

            String strIsDisabled = new String("");

            if(j%2 == 1){
              strClassType = "td-listrom";
            }else{
              strClassType = "";
            }
            j++;
          %>

          <tr onmouseover="this.className='tr-over'" onmouseout="this.className='<%=JspHelper.filterNull(strClassType)%>'"  onClick="javascript:checktrue('conditiondetail<%=JspHelper.filterNull(j)%>');item_onclick('<%=JspHelper.filterNull(j)%>','<%=JspHelper.filterNull(ConditionDetailMap.get("conditiondetailid"))%>')" class="<%=JspHelper.filterNull(strClassType)%>">
            <input type="hidden" name="detailids" value="-1">

            <td width="5%">
              <input id="conditiondetail<%=JspHelper.filterNull(j )%>" type="checkbox" name="checkconditiondetail"  onClick="javascript:checktrue('conditiondetail<%=JspHelper.filterNull(j)%>');item_onclick('<%=JspHelper.filterNull(j)%>','<%=JspHelper.filterNull(ConditionDetailMap.get("conditiondetailid"))%>')" value=<%=JspHelper.filterNull( ConditionDetailMap.get("conditiondetailid") )%> class="checkbox" >
            </td>
            <td>&nbsp;<%=JspHelper.filterNull( ConditionDetailMap.get("sortno") )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( ConditionDetailMap.get("fieldname")!=null?column.getColumnDesc(VTable,(String)ConditionDetailMap.get("fieldname")):"" )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( ConditionDetailMap.get("operator") )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( ConditionDetailMap.get("value") )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( ConditionDetailMap.get("memo") )%></td>
          </tr>
          </logic:iterate>
          <input type="hidden" name="detailids" value="-1">
<%--	        <input type="hidden" name="detailids" value="-1">--%>
<%--	        <input type="hidden" name="detailids" value="-1">--%>


		    <% //--------------------------------------  flipping page --%>
		    <%@ include file="/inc/SummaryAction.inc" %>



        </table>
      </td>
    </tr>
    <tr>
      <td class="summary_top"></td>
    </tr>
    <tr>
      <td class="td_center">
      <a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>&nbsp;
      <a onclick="page_add()"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a>&nbsp;
       <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>&nbsp;
      <a onclick="parent.location.href='ConditionMgmtFrm.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>';"><custom:button type="1" label="L_Back" imgsrc="back.gif" border="0" style="width:60"/></a>
      </td>
    </tr>
    </table>
  </form>
</table>
</body>
</html>


